package com.team.order.domain.query;

import cn.hutool.core.bean.BeanUtil;
import com.team.order.domain.Order;
import com.team.order.domain.dto.OrderDTO;
import lombok.Data;

import java.time.LocalDateTime;

/**
 * @author 梁国瑞
 * @version 1.0
 */
@Data
public class OrderQuery {
    // 订单实体类
    private Order order;
    // 开始时间
    private LocalDateTime startTime;
    // 结束时间
    private LocalDateTime endTime;

    // 将OrderDTO转换成OrderQuery
    public static OrderQuery convertToQuery (OrderDTO orderDTO) {
        OrderQuery orderQuery = new OrderQuery();
        orderQuery.setOrder(BeanUtil.copyProperties(orderDTO, Order.class));
        orderQuery.setStartTime(orderDTO.getStartTime());
        orderQuery.setEndTime(orderDTO.getEndTime());
        return orderQuery;
    }

}
